package com.airlines.crewassignment.service.crewlocation.impl;

import com.airlines.common.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.airlines.crewassignment.service.crewlocation.CrewBackupService;
import com.airlines.crewassignment.entity.crewlocation.CrewBackup;
import java.util.List;
import com.airlines.crewassignment.dao.crewlocation.CrewBackupMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

/**
 * @author xxxx
 * @date 2018/06/25 09:51:34
 * @company xxxx Airlines
 * @description 
 */
@Service
public class CrewBackupServiceImpl implements CrewBackupService {

    @Autowired
    private CrewBackupMapper crewBackupMapper;

    @Override
    public int insert(CrewBackup crewBackup){
        return crewBackupMapper.insert(crewBackup);
    }

    @Override
    public int deleteLogic(String flightDate,String pCode){
        return crewBackupMapper.deleteLogic(flightDate,pCode);
    }


    @Override
    public int update(CrewBackup crewBackup){
        return crewBackupMapper.update(crewBackup);
    }

    @Override
    public CrewBackup get(String flightDate,String pCode){
        return crewBackupMapper.get(flightDate,pCode);
    }

    @Override
    public List<CrewBackup> list(CrewBackup crewBackup){
        return crewBackupMapper.list(crewBackup);
    }

    @Override
    public Page list(CrewBackup crewBackup, Page page){
        PageHelper.startPage(page.getPageNumber(), page.getPageSize());
        List<CrewBackup> list = crewBackupMapper.listByFuzzy(crewBackup);
        PageInfo<CrewBackup> pageInfo = new PageInfo<CrewBackup>(list);
        page.setTotal(String.valueOf(pageInfo.getTotal()));
        page.setRows(pageInfo.getList());
        return page;
    }




}
